<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>  
    <div id="app"></div>
    <template id="txt">
        <div>
            <p v-if="age<18">未成年</p>
            <p v-else-if="age>=18 && age<40">青年</p>
            <p v-else-if="age>=40 && age<60">中年</p>
            <p v-else>老年</p>
            <button @click="flag=true">user</button>
            <button @click="flag=false">pass</button>
            <p v-if="flag">
                username:
                <input type="text" key="a">
            </p>
            <p v-if="!flag">
                password:
                <input type="text" key="b">
            </p>
            <p v-show="false">hhhhhhh</p>
            <!-- 切换频繁时用 -->
            <p v-if="false">ssssssss</p>
            <!-- 运行时条件改变很少时,不是频繁的切换使用v-if -->
        </div>
    </template>
</body>
<script src="/vue.min.js"></script>
<script>
    var vm = new Vue({
        el:'#app',
        template:'#txt',
        data:function(){
            return{
                age:20,
                flag:true
            }
        }
    })
</script>
</html>